﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Svg;
using System.Drawing;
using System.Runtime.Serialization;
using Commons;
using Svg.Pathing;
using Svg.Transforms;

namespace HumanFace
{
    [DataContract]
    public class Nose : Entities.Base.NoseBASE
    {
        public Nose(NodeCollection pointList, Dictionary<string, string> templates)
            : base(templates, pointList)
        {
            CreateProperties();
            RenderVectorelGraphic();
        }
        public Nose()
        {
        }
        private void CreateProperties()
        {
            #region NoseHeight
            Node nd37 = PointList["37"];
            Node nd41 = PointList["41"];
            if (nd37 != null && nd41 != null)
                this.Height = nd41.Y - nd37.Y;
            #endregion
            #region NoseWidth
            Node nd43 = PointList["43"];
            Node nd39 = PointList["39"];
            if (nd39 != null && nd43 != null)
                this.Width = nd43.X - nd39.X;
            #endregion
        }
        protected override void RenderVectorelGraphic()
        {
            base.RenderVectorelGraphic();
            if (this.SVG != null)
            {
                this.SVG.ID = "nose";
                SvgPath leftNose = this.SVG.GetElementById<SvgPath>("leftNose");
                SvgPath rightNose = this.SVG.GetElementById<SvgPath>("rightNose");
                SvgPath bottomNose = this.SVG.GetElementById<SvgPath>("bottomNose");
                SvgPath bottomNoseShadow = this.SVG.GetElementById<SvgPath>("bottomNoseShadow");

                PointF leftOfTemplate = ((SvgCubicCurveSegment)leftNose.PathData[2]).End;
                PointF rightOfTemplate = ((SvgCubicCurveSegment)rightNose.PathData[4]).End;
                PointF topOfTemplate = ((SvgCubicCurveSegment)leftNose.PathData[8]).End;
                PointF bottomOfTemplate = ((SvgCubicCurveSegment)leftNose.PathData[3]).End;
                float templateWidth = rightOfTemplate.X - leftOfTemplate.X;
                float templateHeight = bottomOfTemplate.Y - topOfTemplate.Y;
                float ratioX = templateWidth / this.Width;
                float ratioY = templateHeight / this.Height;

                SetLeftNose(leftNose, ratioX, ratioY);
                SetRightNose(rightNose, ratioX, ratioY);
                SetBottomNose(bottomNose, ratioX, ratioY,false);
                SetBottomNose(bottomNoseShadow, ratioX, ratioY,true);

                SvgTransformCollection transformCollection = new SvgTransformCollection();
                SvgGroup noseGroup = this.SVG.GetElementById<SvgGroup>("noseGroup");
                if (noseGroup.Transforms != null) transformCollection = noseGroup.Transforms;
                SketchHelper.Scale(1 / ratioX, 1 / ratioY, transformCollection);
                noseGroup.Transforms = transformCollection;
            }
        }
        private void SetBottomNose(SvgPath bottomNose, float ratioX, float ratioY, bool shadow)
        {
            
            #region bpathDataProps
            SvgMoveToSegment bpathData0 = ((SvgMoveToSegment)bottomNose.PathData[0]);
            SvgCubicCurveSegment bpathData1 = ((SvgCubicCurveSegment)bottomNose.PathData[1]);
            SvgCubicCurveSegment bpathData2 = ((SvgCubicCurveSegment)bottomNose.PathData[2]);
            SvgCubicCurveSegment bpathData3 = ((SvgCubicCurveSegment)bottomNose.PathData[3]);
            SvgCubicCurveSegment bpathData4 = ((SvgCubicCurveSegment)bottomNose.PathData[4]);
            SvgCubicCurveSegment bpathData5 = ((SvgCubicCurveSegment)bottomNose.PathData[5]);
            SvgCubicCurveSegment bpathData6 = ((SvgCubicCurveSegment)bottomNose.PathData[6]);
            SvgCubicCurveSegment bpathData7 = ((SvgCubicCurveSegment)bottomNose.PathData[7]);
            SvgCubicCurveSegment bpathData8 = ((SvgCubicCurveSegment)bottomNose.PathData[8]);
            SvgCubicCurveSegment bpathData9 = ((SvgCubicCurveSegment)bottomNose.PathData[9]);
            SvgCubicCurveSegment bpathData10 = ((SvgCubicCurveSegment)bottomNose.PathData[10]);
            #endregion
            float shadowX = 0, shadowY = 0;
            if (shadow)
            {
                SvgPath bN = this.SVG.GetElementById<SvgPath>("bottomNose");
                shadowX = bpathData0.End.X - bN.PathData[0].End.X;
                shadowY = bpathData0.End.Y - bN.PathData[0].End.Y;
            }
            #region borderProps
            float border27 = bpathData2.End.Y - bpathData7.End.Y;
            float border09 = bpathData0.End.Y - bpathData9.End.Y;
            float border45 = bpathData4.End.Y - bpathData5.End.Y;
            #endregion
            PointF[] plist = new PointF[11];
            plist[0] = new PointF((this.PointList["46"].X - this.MostLeftPoint.X + shadowX) * ratioX, (this.PointList["46"].Y - this.MostTopPoint.Y + shadowY) * ratioY + border09);
            plist[9] = new PointF((this.PointList["46"].X - this.MostLeftPoint.X + shadowX) * ratioX, (this.PointList["46"].Y - this.MostTopPoint.Y + shadowY) * ratioY);
            plist[10] = plist[0];
            plist[2] = new PointF((this.PointList["41"].X - this.MostLeftPoint.X + shadowX) * ratioX, (this.PointList["41"].Y - this.MostTopPoint.Y + shadowY) * ratioY + border27);
            plist[7] = new PointF((this.PointList["41"].X - this.MostLeftPoint.X + shadowX) * ratioX, (this.PointList["41"].Y - this.MostTopPoint.Y + shadowY) * ratioY);
            plist[4] = new PointF((this.PointList["47"].X - this.MostLeftPoint.X + shadowX) * ratioX, (this.PointList["47"].Y - this.MostTopPoint.Y + shadowY) * ratioY + border45);
            plist[5] = new PointF((this.PointList["47"].X - this.MostLeftPoint.X + shadowX) * ratioX, (this.PointList["47"].Y - this.MostTopPoint.Y + shadowY) * ratioY);
            plist[1] = SketchHelper.CalculateCoordinates(bpathData0.End, bpathData2.End, bpathData1.End, plist[0], plist[2]);
            plist[3] = SketchHelper.CalculateCoordinates(bpathData2.End, bpathData4.End, bpathData3.End, plist[2], plist[4]);
            plist[6] = SketchHelper.CalculateCoordinates(bpathData7.End,bpathData5.End,bpathData6.End,plist[7],plist[5]);
            plist[8] = SketchHelper.CalculateCoordinates(bpathData9.End, bpathData7.End, bpathData8.End, plist[9], plist[7]);
            #region bpathData1
            float bpathData1curveDifferenceX = plist[1].X - bpathData1.End.X;
            float bpathData1curveDifferenceY = plist[1].Y - bpathData1.End.Y;
            //rpathData1.FirstControlPoint = new PointF(rpathData1.FirstControlPoint.X + rpathData0curveDifferenceX, rpathData1.FirstControlPoint.Y + rpathData0curveDifferenceY);
            bpathData1.SecondControlPoint = new PointF(bpathData1.SecondControlPoint.X + bpathData1curveDifferenceX, bpathData1.SecondControlPoint.Y + bpathData1curveDifferenceY);
            bpathData1.End = plist[1];
            //rpathData1.Start = rpathData0.End;
            #endregion
            #region bpathData2
            float bpathData2curveDifferenceX = plist[2].X - bpathData2.End.X;
            float bpathData2curveDifferenceY = plist[2].Y - bpathData2.End.Y;
            bpathData2.FirstControlPoint = new PointF(bpathData2.FirstControlPoint.X + bpathData1curveDifferenceX, bpathData2.FirstControlPoint.Y + bpathData1curveDifferenceY);
            bpathData2.SecondControlPoint = new PointF(bpathData2.SecondControlPoint.X + bpathData2curveDifferenceX, bpathData2.SecondControlPoint.Y + bpathData2curveDifferenceY);
            bpathData2.End = plist[2];
            bpathData2.Start = bpathData1.End;
            #endregion
            //float differenceY34 = rpathData4.End.Y - rpathData3.End.Y;
            #region bpathData3
            float bpathData3curveDifferenceX = plist[3].X - bpathData3.End.X;
            float bpathData3curveDifferenceY = plist[3].Y - bpathData3.End.Y;
            bpathData3.FirstControlPoint = new PointF(bpathData3.FirstControlPoint.X + bpathData2curveDifferenceX, bpathData3.FirstControlPoint.Y + bpathData2curveDifferenceY);
            bpathData3.SecondControlPoint = new PointF(bpathData3.SecondControlPoint.X + bpathData3curveDifferenceX, bpathData3.SecondControlPoint.Y + bpathData3curveDifferenceY);
            bpathData3.End = plist[3];
            bpathData3.Start = bpathData2.End;
            #endregion
            #region bpathData4
            float bpathData4curveDifferenceX = plist[4].X - bpathData4.End.X;
            float bpathData4curveDifferenceY = plist[4].Y - bpathData4.End.Y;
            bpathData4.FirstControlPoint = new PointF(bpathData4.FirstControlPoint.X + bpathData3curveDifferenceX, bpathData4.FirstControlPoint.Y + bpathData3curveDifferenceY);
            bpathData4.SecondControlPoint = new PointF(bpathData4.SecondControlPoint.X + bpathData4curveDifferenceX, bpathData4.SecondControlPoint.Y + bpathData4curveDifferenceY);
            bpathData4.End = plist[4];
            bpathData4.Start = bpathData3.End;
            #endregion
            #region bpathData5
            float bpathData5curveDifferenceX = plist[5].X - bpathData5.End.X;
            float bpathData5curveDifferenceY = plist[5].Y - bpathData5.End.Y;
            bpathData5.FirstControlPoint = new PointF(bpathData5.FirstControlPoint.X + bpathData4curveDifferenceX, bpathData5.FirstControlPoint.Y + bpathData4curveDifferenceY);
            bpathData5.SecondControlPoint = new PointF(bpathData5.SecondControlPoint.X + bpathData5curveDifferenceX, bpathData5.SecondControlPoint.Y + bpathData5curveDifferenceY);
            bpathData5.End = plist[5];
            bpathData5.Start = bpathData4.End;
            #endregion
            #region bpathData6
            float bpathData6curveDifferenceX = plist[6].X - bpathData6.End.X;
            float bpathData6curveDifferenceY = plist[6].Y - bpathData6.End.Y;
            bpathData6.FirstControlPoint = new PointF(bpathData6.FirstControlPoint.X + bpathData5curveDifferenceX, bpathData6.FirstControlPoint.Y + bpathData5curveDifferenceY);
            bpathData6.SecondControlPoint = new PointF(bpathData6.SecondControlPoint.X + bpathData6curveDifferenceX, bpathData6.SecondControlPoint.Y + bpathData6curveDifferenceY);
            bpathData6.End = plist[6];
            bpathData6.Start = bpathData5.End;
            #endregion
            #region bpathData7
            float bpathData7curveDifferenceX = plist[7].X - bpathData7.End.X;
            float bpathData7curveDifferenceY = plist[7].Y - bpathData7.End.Y;
            bpathData7.FirstControlPoint = new PointF(bpathData7.FirstControlPoint.X + bpathData6curveDifferenceX, bpathData7.FirstControlPoint.Y + bpathData6curveDifferenceY);
            bpathData7.SecondControlPoint = new PointF(bpathData7.SecondControlPoint.X + bpathData7curveDifferenceX, bpathData7.SecondControlPoint.Y + bpathData7curveDifferenceY);
            bpathData7.End = plist[7];
            bpathData7.Start = bpathData6.End;
            #endregion
            #region bpathData8
            float bpathData8curveDifferenceX = plist[8].X - bpathData8.End.X;
            float bpathData8curveDifferenceY = plist[8].Y - bpathData8.End.Y;
            bpathData8.FirstControlPoint = new PointF(bpathData8.FirstControlPoint.X + bpathData7curveDifferenceX, bpathData8.FirstControlPoint.Y + bpathData7curveDifferenceY);
            bpathData8.SecondControlPoint = new PointF(bpathData8.SecondControlPoint.X + bpathData8curveDifferenceX, bpathData8.SecondControlPoint.Y + bpathData8curveDifferenceY);
            bpathData8.End = plist[8];
            bpathData8.Start = bpathData7.End;
            #endregion
            #region bpathData9
            float bpathData9curveDifferenceX = plist[9].X - bpathData9.End.X;
            float bpathData9curveDifferenceY = plist[9].Y - bpathData9.End.Y;
            bpathData9.FirstControlPoint = new PointF(bpathData9.FirstControlPoint.X + bpathData8curveDifferenceX, bpathData9.FirstControlPoint.Y + bpathData8curveDifferenceY);
            bpathData9.SecondControlPoint = new PointF(bpathData9.SecondControlPoint.X + bpathData9curveDifferenceX, bpathData9.SecondControlPoint.Y + bpathData9curveDifferenceY);
            bpathData9.End = plist[9];
            bpathData9.Start = bpathData8.End;
            #endregion
            #region bpathData10
            float bpathData10curveDifferenceX = plist[10].X - bpathData10.End.X;
            float bpathData10curveDifferenceY = plist[10].Y - bpathData10.End.Y;
            bpathData10.FirstControlPoint = new PointF(bpathData10.FirstControlPoint.X + bpathData9curveDifferenceX, bpathData10.FirstControlPoint.Y + bpathData9curveDifferenceY);
            bpathData10.SecondControlPoint = new PointF(bpathData10.SecondControlPoint.X + bpathData10curveDifferenceX, bpathData10.SecondControlPoint.Y + bpathData10curveDifferenceY);
            bpathData10.End = plist[10];
            bpathData10.Start = bpathData9.End;
            #endregion
            bpathData0.Start = bpathData10.End;
            bpathData0.End = bpathData10.End;
            bpathData1.Start = bpathData0.End;
            bpathData1.FirstControlPoint = new PointF(bpathData1.FirstControlPoint.X + bpathData10curveDifferenceX, bpathData1.FirstControlPoint.Y + bpathData10curveDifferenceY);
        }
        private void SetRightNose(SvgPath rightNose, float ratioX, float ratioY)
        {
            #region rpathDataProps
            SvgMoveToSegment rpathData0 = ((SvgMoveToSegment)rightNose.PathData[0]);
            SvgCubicCurveSegment rpathData1 = ((SvgCubicCurveSegment)rightNose.PathData[1]);
            SvgCubicCurveSegment rpathData2 = ((SvgCubicCurveSegment)rightNose.PathData[2]);
            SvgCubicCurveSegment rpathData3 = ((SvgCubicCurveSegment)rightNose.PathData[3]);
            SvgCubicCurveSegment rpathData4 = ((SvgCubicCurveSegment)rightNose.PathData[4]);
            SvgCubicCurveSegment rpathData5 = ((SvgCubicCurveSegment)rightNose.PathData[5]);
            SvgCubicCurveSegment rpathData6 = ((SvgCubicCurveSegment)rightNose.PathData[6]);
            #endregion
            #region borderProps
            float border01 = rpathData0.End.X - rpathData1.End.X;
            float border25 = rpathData5.End.X - rpathData2.End.X;
            float border34 = rpathData4.End.X - rpathData3.End.X;

            #endregion
            #region rpathData1
            PointF newrpathData1End = new PointF((this.PointList["44"].X - this.MostLeftPoint.X) * ratioX, (this.PointList["44"].Y - this.MostTopPoint.Y) * ratioY);
            float rpathData1curveDifferenceX = newrpathData1End.X - rpathData1.End.X;
            float rpathData1curveDifferenceY = newrpathData1End.Y - rpathData1.End.Y;
            //rpathData1.FirstControlPoint = new PointF(rpathData1.FirstControlPoint.X + rpathData0curveDifferenceX, rpathData1.FirstControlPoint.Y + rpathData0curveDifferenceY);
            rpathData1.SecondControlPoint = new PointF(rpathData1.SecondControlPoint.X + rpathData1curveDifferenceX, rpathData1.SecondControlPoint.Y + rpathData1curveDifferenceY);
            rpathData1.End = newrpathData1End;
            //rpathData1.Start = rpathData0.End;
            #endregion
            #region rpathData2
            PointF newrpathData2End = new PointF((this.PointList["43"].X - this.MostLeftPoint.X) * ratioX, (this.PointList["43"].Y - this.MostTopPoint.Y) * ratioY);
            float rpathData2curveDifferenceX = newrpathData2End.X - rpathData2.End.X;
            float rpathData2curveDifferenceY = newrpathData2End.Y - rpathData2.End.Y;
            rpathData2.FirstControlPoint = new PointF(rpathData2.FirstControlPoint.X + rpathData1curveDifferenceX, rpathData2.FirstControlPoint.Y + rpathData1curveDifferenceY);
            rpathData2.SecondControlPoint = new PointF(rpathData2.SecondControlPoint.X + rpathData2curveDifferenceX, rpathData2.SecondControlPoint.Y + rpathData2curveDifferenceY);
            rpathData2.End = newrpathData2End;
            rpathData2.Start = rpathData1.End;
            #endregion
            float differenceY34 = rpathData4.End.Y - rpathData3.End.Y;
            #region rpathData3
            PointF newrpathData3End = new PointF((this.PointList["42"].X - this.MostLeftPoint.X) * ratioX, (this.PointList["42"].Y - this.MostTopPoint.Y) * ratioY);
            float rpathData3curveDifferenceX = newrpathData3End.X - rpathData3.End.X;
            float rpathData3curveDifferenceY = newrpathData3End.Y - rpathData3.End.Y;
            rpathData3.FirstControlPoint = new PointF(rpathData3.FirstControlPoint.X + rpathData2curveDifferenceX, rpathData3.FirstControlPoint.Y + rpathData2curveDifferenceY);
            rpathData3.SecondControlPoint = new PointF(rpathData3.SecondControlPoint.X + rpathData3curveDifferenceX, rpathData3.SecondControlPoint.Y + rpathData3curveDifferenceY);
            rpathData3.End = newrpathData3End;
            rpathData3.Start = rpathData2.End;
            #endregion
            #region rpathData4
            PointF newrpathData4End = new PointF((this.PointList["42"].X - this.MostLeftPoint.X) * ratioX, (this.PointList["42"].Y - this.MostTopPoint.Y) * ratioY + differenceY34);
            float rpathData4curveDifferenceX = newrpathData4End.X - rpathData4.End.X;
            float rpathData4curveDifferenceY = newrpathData4End.Y - rpathData4.End.Y;
            rpathData4.FirstControlPoint = new PointF(rpathData4.FirstControlPoint.X + rpathData3curveDifferenceX, rpathData4.FirstControlPoint.Y + rpathData3curveDifferenceY);
            rpathData4.SecondControlPoint = new PointF(rpathData4.SecondControlPoint.X + rpathData4curveDifferenceX, rpathData4.SecondControlPoint.Y + rpathData4curveDifferenceY);
            rpathData4.End = newrpathData4End;
            rpathData4.Start = rpathData3.End;
            #endregion
            #region rpathData5
            PointF newrpathData5End = new PointF((this.PointList["43"].X - this.MostLeftPoint.X) * ratioX + border25, (this.PointList["43"].Y - this.MostTopPoint.Y) * ratioY);
            float rpathData5curveDifferenceX = newrpathData5End.X - rpathData5.End.X;
            float rpathData5curveDifferenceY = newrpathData5End.Y - rpathData5.End.Y;
            rpathData5.FirstControlPoint = new PointF(rpathData5.FirstControlPoint.X + rpathData4curveDifferenceX, rpathData5.FirstControlPoint.Y + rpathData4curveDifferenceY);
            rpathData5.SecondControlPoint = new PointF(rpathData5.SecondControlPoint.X + rpathData5curveDifferenceX, rpathData5.SecondControlPoint.Y + rpathData5curveDifferenceY);
            rpathData5.End = newrpathData5End;
            rpathData5.Start = rpathData4.End;
            #endregion
            #region rpathData6
            PointF newrpathData6End = new PointF((this.PointList["44"].X - this.MostLeftPoint.X) * ratioX + border01, (this.PointList["44"].Y - this.MostTopPoint.Y) * ratioY);
            float rpathData6curveDifferenceX = newrpathData6End.X - rpathData6.End.X;
            float rpathData6curveDifferenceY = newrpathData6End.Y - rpathData6.End.Y;
            rpathData6.FirstControlPoint = new PointF(rpathData6.FirstControlPoint.X + rpathData5curveDifferenceX, rpathData6.FirstControlPoint.Y + rpathData5curveDifferenceY);
            rpathData6.SecondControlPoint = new PointF(rpathData6.SecondControlPoint.X + rpathData6curveDifferenceX, rpathData6.SecondControlPoint.Y + rpathData6curveDifferenceY);
            rpathData6.End = newrpathData6End;
            rpathData6.Start = rpathData5.End;
            #endregion
            rpathData0.Start = rpathData6.End;
            rpathData0.End = rpathData6.End;
            rpathData1.Start = rpathData0.End;
            rpathData1.FirstControlPoint = new PointF(rpathData1.FirstControlPoint.X + rpathData6curveDifferenceX, rpathData1.FirstControlPoint.Y + rpathData6curveDifferenceY);
        }
        private void SetLeftNose(SvgPath leftNose, float ratioX, float ratioY)
        {
            #region lpathDataProps
            SvgMoveToSegment lpathData0 = ((SvgMoveToSegment)leftNose.PathData[0]);
            SvgCubicCurveSegment lpathData1 = ((SvgCubicCurveSegment)leftNose.PathData[1]);
            SvgCubicCurveSegment lpathData2 = ((SvgCubicCurveSegment)leftNose.PathData[2]);
            SvgCubicCurveSegment lpathData3 = ((SvgCubicCurveSegment)leftNose.PathData[3]);
            SvgCubicCurveSegment lpathData4 = ((SvgCubicCurveSegment)leftNose.PathData[4]);
            SvgCubicCurveSegment lpathData5 = ((SvgCubicCurveSegment)leftNose.PathData[5]);
            SvgCubicCurveSegment lpathData6 = ((SvgCubicCurveSegment)leftNose.PathData[6]);
            SvgCubicCurveSegment lpathData7 = ((SvgCubicCurveSegment)leftNose.PathData[7]);
            SvgCubicCurveSegment lpathData8 = ((SvgCubicCurveSegment)leftNose.PathData[8]);
            #endregion
            #region borderProps
            float border16 = lpathData6.End.X - lpathData1.End.X;
            float border25 = lpathData5.End.X - lpathData2.End.X;
            float border34 = lpathData4.End.X - lpathData3.End.X;
            float border78 = lpathData7.End.X - lpathData8.End.X;

            //border16 = 0;
            //border25 = 0;
            //border34 = 0;
            //border78 = 0;
            #endregion
            #region lpathData1
            PointF newlpathData1End = new PointF((this.PointList["38"].X - this.MostLeftPoint.X) * ratioX, (this.PointList["38"].Y - this.MostTopPoint.Y) * ratioY);
            float lpathData1curveDifferenceX = newlpathData1End.X - lpathData1.End.X;
            float lpathData1curveDifferenceY = newlpathData1End.Y - lpathData1.End.Y;
            //lpathData1.FirstControlPoint = new PointF(lpathData1.FirstControlPoint.X + lpathData1curveDifferenceX, lpathData1.FirstControlPoint.Y);
            lpathData1.SecondControlPoint = new PointF(lpathData1.SecondControlPoint.X + lpathData1curveDifferenceX, lpathData1.SecondControlPoint.Y + lpathData1curveDifferenceY);
            lpathData1.End = newlpathData1End;
            //lpathData1.Start = lpathData7.End;
            #endregion
            #region lpathData2
            PointF newlpathData2End = new PointF((this.PointList["39"].X - this.MostLeftPoint.X) * ratioX, (this.PointList["39"].Y - this.MostTopPoint.Y) * ratioY);
            float lpathData2curveDifferenceX = newlpathData2End.X - lpathData2.End.X;
            float lpathData2curveDifferenceY = newlpathData2End.Y - lpathData2.End.Y;
            lpathData2.FirstControlPoint = new PointF(lpathData2.FirstControlPoint.X + lpathData1curveDifferenceX, lpathData2.FirstControlPoint.Y + lpathData1curveDifferenceY);
            lpathData2.SecondControlPoint = new PointF(lpathData2.SecondControlPoint.X + lpathData2curveDifferenceX, lpathData2.SecondControlPoint.Y + lpathData2curveDifferenceY);
            lpathData2.End = newlpathData2End;
            lpathData2.Start = lpathData1.End;
            #endregion
            float differenceY34 = lpathData4.End.Y - lpathData3.End.Y;
            #region lpathData3
            PointF newlpathData3End = new PointF((this.PointList["40"].X - this.MostLeftPoint.X) * ratioX, (this.PointList["40"].Y - this.MostTopPoint.Y) * ratioY);
            float lpathData3curveDifferenceX = newlpathData3End.X - lpathData3.End.X;
            float lpathData3curveDifferenceY = newlpathData3End.Y - lpathData3.End.Y;
            lpathData3.FirstControlPoint = new PointF(lpathData3.FirstControlPoint.X + lpathData2curveDifferenceX, lpathData3.FirstControlPoint.Y + lpathData2curveDifferenceY);
            lpathData3.SecondControlPoint = new PointF(lpathData3.SecondControlPoint.X + lpathData3curveDifferenceX, lpathData3.SecondControlPoint.Y + lpathData3curveDifferenceY);
            lpathData3.End = newlpathData3End;
            lpathData3.Start = lpathData2.End;
            #endregion
            #region lpathData4
            PointF newlpathData4End = new PointF((this.PointList["40"].X - this.MostLeftPoint.X) * ratioX + border34, (this.PointList["40"].Y - this.MostTopPoint.Y) * ratioY + differenceY34);
            float lpathData4curveDifferenceX = newlpathData4End.X - lpathData4.End.X;
            float lpathData4curveDifferenceY = newlpathData4End.Y - lpathData4.End.Y;
            lpathData4.FirstControlPoint = new PointF(lpathData4.FirstControlPoint.X + lpathData3curveDifferenceX, lpathData4.FirstControlPoint.Y + lpathData3curveDifferenceY);
            lpathData4.SecondControlPoint = new PointF(lpathData4.SecondControlPoint.X + lpathData4curveDifferenceX, lpathData4.SecondControlPoint.Y + lpathData4curveDifferenceY);
            lpathData4.End = newlpathData4End;
            lpathData4.Start = lpathData3.End;
            #endregion
            #region lpathData5
            PointF newlpathData5End = new PointF((this.PointList["39"].X - this.MostLeftPoint.X) * ratioX + border25, (this.PointList["39"].Y - this.MostTopPoint.Y) * ratioY);
            float lpathData5curveDifferenceX = newlpathData5End.X - lpathData5.End.X;
            float lpathData5curveDifferenceY = newlpathData5End.Y - lpathData5.End.Y;
            lpathData5.FirstControlPoint = new PointF(lpathData5.FirstControlPoint.X + lpathData4curveDifferenceX, lpathData5.FirstControlPoint.Y + lpathData4curveDifferenceY);
            lpathData5.SecondControlPoint = new PointF(lpathData5.SecondControlPoint.X + lpathData5curveDifferenceX, lpathData5.SecondControlPoint.Y + lpathData5curveDifferenceY);
            lpathData5.End = newlpathData5End;
            lpathData5.Start = lpathData4.End;
            #endregion
            #region lpathData6
            PointF newlpathData6End = new PointF((this.PointList["38"].X - this.MostLeftPoint.X) * ratioX + border16, (this.PointList["38"].Y - this.MostTopPoint.Y) * ratioY);
            float lpathData6curveDifferenceX = newlpathData6End.X - lpathData6.End.X;
            float lpathData6curveDifferenceY = newlpathData6End.Y - lpathData6.End.Y;
            lpathData6.FirstControlPoint = new PointF(lpathData6.FirstControlPoint.X + lpathData5curveDifferenceX, lpathData6.FirstControlPoint.Y + lpathData5curveDifferenceY);
            lpathData6.SecondControlPoint = new PointF(lpathData6.SecondControlPoint.X + lpathData6curveDifferenceX, lpathData6.SecondControlPoint.Y + lpathData6curveDifferenceY);
            lpathData6.End = newlpathData6End;
            lpathData6.Start = lpathData5.End;
            #endregion
            #region lpathData7
            PointF newlpathData7End = new PointF((this.PointList["37"].X - this.MostLeftPoint.X) * ratioX + border78, (this.PointList["37"].Y - this.MostTopPoint.Y) * ratioY);
            float lpathData7curveDifferenceX = newlpathData7End.X - lpathData7.End.X;
            float lpathData7curveDifferenceY = newlpathData7End.Y - lpathData7.End.Y;
            lpathData7.FirstControlPoint = new PointF(lpathData7.FirstControlPoint.X + lpathData6curveDifferenceX, lpathData7.FirstControlPoint.Y + lpathData6curveDifferenceY);
            lpathData7.SecondControlPoint = new PointF(lpathData7.SecondControlPoint.X + lpathData7curveDifferenceX, lpathData7.SecondControlPoint.Y + lpathData7curveDifferenceY);
            lpathData7.End = newlpathData7End;
            lpathData7.Start = lpathData6.End;
            #endregion
            #region lpathData8
            PointF newlpathData8End = new PointF((this.PointList["37"].X - this.MostLeftPoint.X) * ratioX, (this.PointList["37"].Y - this.MostTopPoint.Y) * ratioY);
            float lpathData8curveDifferenceX = newlpathData8End.X - lpathData8.End.X;
            float lpathData8curveDifferenceY = newlpathData8End.Y - lpathData8.End.Y;
            lpathData8.FirstControlPoint = new PointF(lpathData8.FirstControlPoint.X + lpathData7curveDifferenceX, lpathData8.FirstControlPoint.Y + lpathData7curveDifferenceY);
            lpathData8.SecondControlPoint = new PointF(lpathData8.SecondControlPoint.X + lpathData8curveDifferenceX, lpathData8.SecondControlPoint.Y + lpathData8curveDifferenceY);
            lpathData8.End = newlpathData8End;
            lpathData8.Start = lpathData7.End;
            #endregion
            lpathData0.Start = lpathData8.End;
            lpathData0.End = lpathData8.End;
            lpathData1.Start = lpathData0.End;
            lpathData1.FirstControlPoint = new PointF(lpathData1.FirstControlPoint.X + lpathData8curveDifferenceX, lpathData1.FirstControlPoint.Y + lpathData8curveDifferenceY);
        }
    }
}
